<!-- list is beginning -->
<div class="cont">
    <style type="text/css">
        .ui.form .inline.fields>label {
            white-space: nowrap;
        }
        
        .ui.add.modal label {
            width: 65px;
        }
        
        .ui.edit.modal label {
            width: 65px;
        }
        
        .ui.modal .ui.form .inline.fields {
            margin: 0.5em;
        }
        
        .ui.modal .ui.pointing.menu {
            margin-bottom: 1em;
            background: transparent;
            border: 1px solid rgba(34, 36, 38, .15)
        }
        
        button.normal_btn {
            border-radius: 16px;
            width: 84px;
            height: 32px;
            border: none;
            color: #fff;
            margin-right: 14px;
            font-size: 14px;
            background: #39A0ED;
            outline: none;
        }
        
        button.normal_btn:hover {
            background: #078ef2;
        }
        
        .onload_checkbox {
            margin: 0 0.4em 0 1.2em;
        }
        
        .onload_checkbox {
            margin: 0 1em;
        }
        
        .ui.form textarea {
            padding-left: 0.5em;
            padding-right: 0.5em;
        }
        
        .addfile {
            padding: 2px 0 2px 8px;
            background: #eee;
            margin-right: 5px;
        }
        
        .padded.grid {
            background: #fff;
            border-radius: 4px;
            box-shadow: 2px 2px 2px rgba(0, 27, 64, 0.1);
            min-height: 850px;
        }
        
        .padded.grid .column .segment {
            min-height: 800px;
        }
        
        .add_post {
            margin-bottom: 16px;
        }
        
        .ui.cards>.card>.extra {
            padding: 0em;
        }
        
        .left.col {
            width: 290px;
            float: left;
            border-right: 1px dashed #e5e5e5;
        }
        
        .add_node {
            font-size: 0.8em;
        }
        
        .treemenu {
            margin-top: 10px;
        }
        
        .header {
            font-size: 16px;
            line-height: 32px;
        }
        
        .header img {
            width: 32px;
            vertical-align: middle;
            margin-right: 10px;
        }
        
        .ui.grid>* {
            padding: 12px;
        }
        
        .right.col {
            width: calc(100% - 290px);
        }
        
        .right.col .konw_title a:nth-child(2) {
            margin-left: 24px;
        }
        
        .right.col .konw_title a:last-child {
            margin-left: 16px;
        }
        
        .right.col .set_department {
            margin: 16px 0 8px 0
        }
        
        .right.col .set_department a {
            margin-right: 12px;
        }
        
        .right.col .set_people {
            margin: 20px 0 8px 0;
        }
        
        .right.col .set_people a {
            margin-right: 12px;
        }
        
        .right.col .set_content {
            background: #f8f8f8;
            padding: 12px;
        }
        
        .right.col .angle.icon {
            cursor: pointer;
        }
        
        .points {
            margin-bottom: 16px;
            height: 40px;
            overflow: hidden;
        }
        
        .points:last-child {
            margin-bottom: 0;
        }
        
        .points div {
            height: 28px;
            line-height: 26px;
            padding: 0 1em;
            border: 1px solid #e2e2e2;
            background: #f2f2f2;
            border-radius: 15px;
            margin-right: 1em;
            margin-top: 10px;
        }
        
        .ui.accordion:not(.styled) .accordion .title~.content:not(.ui),
        .ui.accordion:not(.styled) .title~.content:not(.ui) {
            padding: 0;
        }
        
        .ui.accordion .accordion {
            margin: 0
        }
        
        .ui.accordion .checked.title:not(.ui) {
            color: #39a0ed;
        }
        
        .sector.modal .sector_checkbox {
            padding: 0 6px;
        }
        
        .sector.modal .ui.checkbox {
            margin: 0 3px;
        }
        
        .edituser.modal .sector_checkbox {
            padding: 0 6px;
        }
        
        .edituser.modal .ui.checkbox {
            margin: 0 3px;
        }
        
        .mt8 {
            margin-top: 8px;
        }
        
        .font13 {
            font-size: 13px;
        }
        
        .edituser .ui.form .inline.field>label {
            width: 65px;
        }
        
        .point {
            height: 28px;
            line-height: 26px;
            padding: 0 1em;
            border: 1px solid #999;
            border-radius: 15px;
            margin-right: 1em;
            margin-bottom: 10px;
        }
        
        .edituser .ui.form {
            padding-right: 426px;
        }
    </style>
    <div>
        <div class="position "><img alt="位置图标" src="dist/images/position.png" />知识库>节点管理
        </div>
        <!--vieving style-->
        <div class="ui padded grid">
            <!--知识库管理部门-->
            <div class="left col">
                <div class="header">
                    <img src="dist/images/know_list.png" alt="" />知识树
                    <div class="add_node fr"><a ng-click="AddKnowledgeRight()">添加节点</a></div>
                </div>
                <div class="treemenu boxed">

                </div>
            </div>
            <div class="right col">
                <div class="add_post clearfix">
                    <div class="header fl">
                        <img src="dist/images/know_post.png" />节点权限
                    </div>
                </div>
                <div class="konw_title"><b>{{knowledgespotname}}</b><a href="javascript:;" ng-hide="is_hide" ng-click="DeleteKnowledgeNode()">删除</a><a href="javascript:;" ng-hide="is_hide" ng-click="EditKnowledgeRight()">编辑</a></div>
                <div class="set_department"><b>公司部门节点</b><a href="javascript:;" class="fr" ng-hide="hide_setting" ng-click="ModifySectorRight()">设置</a></div>
                <div class="set_content">
                    <div>拥有查看权限 <i class="angle down icon fr"></i></div>
                    <div class="clearfix points">
                        <div ng-repeat="r in editsectorparam.sectorreadonly" class="fl">{{r}}</div>
                    </div>
                    <div>拥有发布权限<i class="angle down icon fr"></i></div>
                    <div class="clearfix points">
                        <div ng-repeat="w in editsectorparam.sectorwrite" class="fl">{{w}}</div>
                    </div>
                </div>
                <div class="set_people"><b>公司员工</b><a href="javascript:;" class="fr" ng-hide="hide_setting" ng-click="ModifyUserRight()">设置</a></div>
                <div class="set_content">
                    <div>拥有查看权限<i class="angle down icon fr"></i></div>
                    <div class="clearfix points">
                        <div ng-repeat="r in edituserparam.readonly" class="fl">{{r}}</div>
                    </div>
                    <div>拥有发布权限<i class="angle down icon fr"></i></div>
                    <div class="clearfix points">
                        <div ng-repeat="w in edituserparam.write" class="fl">{{w}}</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- list is the end -->
<!--add model is beginning-->
<div class="ui small add modal">
    <i class="close icon"></i>
    <div class="header_h4">
        添加节点
    </div>
    <div class="content">
        <form class="ui form" name="knowledge_spot_add" id="knowledge_spot_add">
            <div class="inline field required">
                <label class="label_fl">节点名称</label>
                <input type="text" placeholder="节点名称" name="addknowledgespot" ng-model="param.addknowledgespot" style="width:60%">
            </div>
            <div class="inline field required">
                <label class="label_fl">节点编码</label>
                <input type="text" ng-model="param.addknowledgecode" id="addnodecode" name="addknowledgecode" placeholder="节点编码" style="width:60%">
            </div>
            <div class="inline field required clearfix" ng-show="param.display && is_showlevelmanager">
                <!--<div class="inline field required clearfix">-->
                <label class="fl" style="line-height:32px;">设置管理员</label>
                <input type="hidden" name="addknowledgeadmin" id="addknowledgeadmin" />
                <div angucomplete-alt id="addknowledgeadminId" class="fl" placeholder="设置管理员" maxlength="50" name="ConMsgUserManager" pause="100" selected-object="addknowledgeadminselect" local-data="addknowledgeadminData" search-fields="nickname" title-field="nickname"
                    minlength="1" input-class="form-control form-control-small" match-class="highlight" input-changed="addknowledgeadmininputChanged" focus-first='true' style="border: none;  width:60%" disable-input="disableInput"></div>
            </div>
        </form>
    </div>
    <div class="actions">
        <div class="ui green button positive">确定</div>
        <button class="ui grey button negative">取消</button>
    </div>
</div>
<!--add model is the end-->
<!--edit model is beginning-->
<div class="ui small edit modal">
    <i class="close icon"></i>
    <div class="header_h4">
        编辑节点
    </div>
    <div class="content">
        <form class="ui form" name="knowledge_spot_edit" id="knowledge_spot_edit">
            <div class="inline field required">
                <label class="label_fl">节点名称</label>
                <input type="text" placeholder="节点名称" name="editknowledgespot" ng-model="editparam.editknowledgespot">
            </div>
            <div class="inline field required">
                <label class="label_fl">节点编码</label>
                <input type="text" ng-model="editparam.editknowledgecode" name="editknowledgecode" id="editnodecode" placeholder="节点编码">
            </div>
            <div class="inline field required" ng-show="editparam.display && editparam.is_show && is_editshowlevelmanager">
                <label>设置管理员</label>
                <input type="hidden" name="editknowledgeadmin" id="editknowledgeadmin" />
                <div angucomplete-alt id="editknowledgeadminId" class="fl" placeholder="设置管理员" maxlength="50" name="ConMsgUserManager" pause="100" selected-object="editknowledgeadminselect" local-data="editknowledgeadminData" search-fields="nickname" title-field="nickname"
                    minlength="1" input-class="form-control form-control-small" match-class="highlight" input-changed="editknowledgeadmininputChanged" focus-first='true' disable-input="editdisableInput">
                </div>
            </div>
        </form>
    </div>
    <div class="actions">
        <div class="ui green button positive">确定</div>
        <button class="ui grey button negative">取消</button>
    </div>

</div>
<!--edit  model is the end-->
<!--modify knowledge spot in sector is beginning-->
<div class="ui small sector modal">
    <i class="close icon"></i>
    <div class="header_h4">
        部门权限管理
    </div>
    <div class="content">
        <div style="max-height:500px; overflow: auto;">
            <div class="clearfix"><span class="fr sector_checkbox font13">发布</span><span class="fr sector_checkbox font13">查看</span></div>
            <form class="ui form mt8" name="knowledge_spot_sector_edit" id="knowledge_spot_sector_edit">
            </form>
        </div>

        <div class="mt8 font13"><b>查看权限</b></div>
        <div class="ui segment" style="min-height: 100px;">
            <div ng-repeat="r in editsectorparam.sectorreadonly" class="fl point">{{r}}</div>
        </div>
        <div><b class="font13">发布权限</b></div>
        <div class="ui segment" style="min-height:100px;">
            <div ng-repeat="w in editsectorparam.sectorwrite" class="fl point">{{w}}</div>
        </div>
    </div>
    <div class="actions">
        <div class="ui green button positive">确定</div>
        <button class="ui grey button negative">取消</button>
    </div>
</div>
<!--modify knowledge spot in sector is the ending-->
<!--modify knowledge spot in user is beginning-->
<div class="ui edituser modal">
    <i class="close icon"></i>
    <div class="header_h4">
        员工权限管理
    </div>
    <div class="content clearfix">
        <form class="ui form" name="knowledge_spot_user_edit" id="knowledge_spot_user_edit">
            <div class="fl" style="width: 50%">
                <div class="inline field">
                    <label>所属分公司</label>
                    <select ng-model="edituserparam.subcompany" class="ui dropdown" ng-options="sub.sector_id as sub.sector_name for sub in editcallsubcompany" id="subcompany">
                        <option value="" selected disabled hidden>所属分公司</option>
                    </select>
                </div>
                <div class="inline field">
                    <label>所属部门</label>
                    <select ng-model="edituserparam.sector" class="ui dropdown" ng-options="sec.sector_id as sec.sector_name for sec in EditSectorSource" id="sector">
                        <option value="" selected disabled hidden>所属部门</option>
                    </select>
                </div>
                <div style="max-height: 200px; overflow: auto">
                    <div class="clearfix" ng-if="edituserparam.sector"><span class="fr sector_checkbox font13">发布</span><span class="fr sector_checkbox font13">查看</span></div>
                    <div ng-repeat="(k,v) in edituserright" class="clearfix">
                        <div style="line-height: 1.6em; color: #333;" class="fl">{{v.nickname}}</div>
                        <div class="ui checkbox fr">
                            <input type="checkbox" name="edit[writeright][]" value="{{v.user_id}}" ng-click="EditWriteRight(k)">
                            <label></label>
                        </div>
                        <div class="ui checkbox fr">
                            <input type="checkbox" name="edit[readonlyright][]" value="{{v.user_id}}" ng-click="EditOnlyReadRight(k)">
                            <label></label>
                        </div>
                    </div>
                </div>

            </div>
        </form>
        <div class="fr" style="width: 60%">
            <div class="font13"><b>查看权限</b></div>
            <div class="ui segment" style="min-height: 100px;">
                <div ng-repeat="r in edituserparam.readonly" class="fl point">{{r}}</div>
            </div>
            <div><b class="font13">发布权限</b></div>
            <div class="ui segment" style="min-height:100px;">
                <div ng-repeat="w in edituserparam.write" class="fl point">{{w}}</div>
            </div>
        </div>
    </div>
    <div class="actions">
        <div class="ui green button positive">确定</div>
        <button class="ui grey button negative">取消</button>
    </div>
</div>
<!--modify knowledge spot in user is the ending-->
<!--delete knowledge node is beginning-->
<div class="ui modal modal3" id="conflict_del">
    <div class="header_h4" style="text-align: center;">删除知识节点</div>
    <div class="content" style="text-align: center;">
        <i class="huge blue help circle icon"></i>
        <p style="padding-top: 15px;">确认删除该知识节点相关信息吗?</p>
    </div>
    <div class="actions" style="text-align: center;">
        <div class="ui positive button">确定</div>
        <button class="ui grey button negative">取消</button>
    </div>
</div>
<!--delege knowledge node is the end-->
<!--add success-->
<div class="ui modal modal1" style="text-align: center;">
    <div class="header center aligned">提示</div>
    <div class="content center aligned">
        <i class="huge green check circle outline icon"></i>
        <p style="padding-top: 15px;">添加成功</p>
    </div>
</div>
<!--add success-->
<div class="ui modal modal2" style="text-align: center;">
    <div class="header center aligned">提示</div>
    <div class="content center aligned">
        <i class="huge red remove circle outline icon"></i>
        <p style="padding-top: 15px;">添加失败</p>
    </div>
</div>
<!--编辑成功-->
<div class="ui small modal editOk" style="text-align: center;">
    <div class="header">提示</div>
    <div class="content">
        <i class="huge green check circle outline icon"></i>
        <p style="padding-top: 15px;">编辑成功</p>
    </div>
</div>
<!--编辑失败-->
<div class="ui modal editFail" style="text-align: center;">
    <div class="header">提示</div>
    <div class="content">
        <i class="huge red warning outline icon"></i>
        <p style="padding-top: 15px;">编辑失败</p>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function() {
        $('.angle.icon').click(function() {
            if ($(this).hasClass('down')) {
                $(this).addClass("up").removeClass("down");
                $(this).parent().next().css("height", "auto");
            } else {
                $(this).addClass("down").removeClass("up");
                $(this).parent().next().css("height", "40px");
            }
        })
        $('.ui.dropdown').dropdown();
    })

    $(function() {
        $('.ui.dropdown').dropdown();
        $.fn.form.settings.rules.code = function() {
            var varify = false;
            var code = this[0].value.length;
            if (code % 2 == 0) {
                varify = true;
            }
            return varify;
        }

        $.fn.form.settings.rules.coderange = function() {
            var cd = this[0].value.length;
            var codevarify;
            $.ajax({
                method: "POST",
                url: "/Admin/Knowledgeright/CodeRange",
                data: {
                    code: cd
                },
                success: function(msg) {
                    if (msg === 'true') {
                        codevarify = true;
                    } else {
                        codevarify = false;
                    }
                },
                async: false
            });
            return codevarify;
        }

        $.fn.form.settings.rules.is_same = function() {
            var IS = this[0].value;
            var isSame;
            $.ajax({
                method: "POST",
                url: "/Admin/Knowledgeright/IsSameCode",
                data: {
                    code: IS
                },
                success: function(msg) {
                    if (msg === 'true') {
                        isSame = true;
                    } else {
                        isSame = false;
                    }
                },
                async: false
            });
            return isSame;
        }

        // edit validate
        $.fn.form.settings.rules.is_display = function() {
            var val = this[0].value;
            if ($('#addnodecode').val().length > 2) {
                return true;
            } else {
                if (val) {
                    return true;
                } else {
                    return false;
                }
            }
        }

        $.fn.form.settings.rules.is_editdisplay = function() {
            var val = this[0].value;
            if ($('#editnodecode').val().length > 2) {
                return true;
            } else {
                if (val) {
                    return true;
                } else {
                    return false;
                }
            }
        }

        // $.fn.form.settings.rules.is_level_one = function() {
        //     var val = this[0].value;
        //     if ($('#addnodecode').val().length > 2) {
        //         return true;
        //     } else {
        //         if (val) {
        //             return true;
        //         } else {
        //             return false;
        //         }
        //     }
        // }

        // $.fn.form.settings.rules.is_level_one_edit = function() {
        //     var editval = this[0].value;
        //     if ($('#editnodecode').val().length > 2) {
        //         return true;
        //     } else {
        //         if (editval) {
        //             return true;
        //         } else {
        //             return false;
        //         }
        //     }
        // }

        $('#knowledge_spot_add').form({
            on: 'blur',
            inline: true,
            fields: {
                addknowledgespot: {
                    identifier: 'addknowledgespot',
                    rules: [{
                        type: 'empty',
                        prompt: '节点名称不能为空'
                    }]
                },
                addknowledgecode: {
                    identifier: 'addknowledgecode',
                    rules: [{
                        type: 'minLength[2]',
                        prompt: '节点编码最少为两位'
                    }, {
                        type: 'code',
                        prompt: '节点编码规范错误'
                    }, {
                        type: 'coderange',
                        prompt: '节点编码填写超出范围'
                    }, {
                        type: 'is_same',
                        prompt: '节点编码已经存在'
                    }]
                },
                addknowledgeadmin: {
                    identifier: 'addknowledgeadmin',
                    rules: [{
                        type: 'is_display',
                        prompt: '一级管理员不能为空'
                    }]
                }
            }
        });

        setTimeout(function() {
            registerHiddenBlur('addknowledgeadmin', 'addknowledgeadminId_value');
        }, 200);

        $('#knowledge_spot_edit').form({
            on: 'blur',
            inline: true,
            fields: {
                editknowledgespot: {
                    identifier: 'editknowledgespot',
                    rules: [{
                        type: 'empty',
                        prompt: '节点名称不能为空'
                    }]
                },
                editknowledgecode: {
                    identifier: 'editknowledgecode',
                    rules: [{
                        type: 'minLength[2]',
                        prompt: '节点编码最少为两位'
                    }, {
                        type: 'code',
                        prompt: '节点编码规范错误'
                    }, {
                        type: 'coderange',
                        prompt: '节点编码填写超出范围'
                    }]
                },
                editknowledgeadmin: {
                    identifier: 'editknowledgeadmin',
                    rules: [{
                        type: 'is_editdisplay',
                        prompt: '一级管理员不能为空'
                    }]
                }
            }
        });

        setTimeout(function() {
            registerHiddenBlur('editknowledgeadmin', 'editknowledgeadminId_value');
        }, 200);
    });

    function registerHiddenBlur(hiddenID, visibleID) {
        $('#' + visibleID).blur(function() {
            //延时触发blur，目的是让hidden input先于blur被赋值
            setTimeout(function() {
                $('#' + hiddenID).trigger('blur');
            }, 100);
        });
    }
</script>